import Api from '../../constants/Api'

export default {
  namespaced: true,
  state: {
    warningList: []
  },
  mutations: {
    warningListTo(state, data) {
      state.warningList = data
    }
  },
  actions: {
    getWarningList({
      commit
    }, that) {
      that.$axios({
        method: 'get',
        url: Api.queryWarning
      }).then(res => {
        if (res.code === 20001) {
          commit('warningListTo', res.data)
          that.tableLoading = false
        } else {
          that.$message.error(res.msg)
        }
      })
    },
    editWarning({
      commit
    }, that) {
      that.$axios({
        method: 'post',
        url: Api.editWarning,
        data: [that.warningForm]
      }).then(res => {
        if (res.code === 20000) {
          that.$message.success(res.msg)
          that.getData()
          that.handleVisible = false
        } else {
          that.$message.error(res.msg)
        }
      })
    }
  }
}